let passport = require('passport')
let LinkedInStrategy = require('passport-linkedin')

// let User = require('../models/user')
let config = require('../_config')
let init = require('./init')

passport.use(new LinkedInStrategy(
  {
    consumerKey: config.linkedin.clientID,
    consumerSecret: config.linkedin.clientSecret,
    callbackURL: config.linkedin.callbackURL
  },
  function (token, tokenSecret, profile, done) {
    let searchQuery = {
      name: profile.displayName
    }

    let updates = {
      name: profile.displayName,
      someID: profile.id
    }

    let options = {
      upsert: true
    }

/*     User.findOneAndUpdate(searchQuery, updates, options, function(err, user) {
      if (err) {
        return done(err)
      } else {
        return done(null, user)
      }
    }) */
  }
))

init()

module.exports = passport